# -*- coding: utf-8 -*-

 ###############################################
 ##                                             ##
 ##  config                                      ##
 ##                                              ##
 ##                                              ##
 ##  for Basiq Series                            ##
 ##  by Críptidos Digitales                      ##
 ##  GPL (c)2005                                 ##
  ##                                             ##
    ###############################################

from utilities import ConfigParser


filename = ''

class Parser(ConfigParser):

    def __init__(self, **kwds):     # print "ConfigParser.__init__()"
        
        global filename
        
        if 'filename' in kwds.keys():
            filename = kwds['filename']
        else:
            if filename:
                kwds['filename'] = filename
        
        ConfigParser.__init__(self, **kwds)
        try:
            self.init()
        except:
            pass


    def init(self):
        self.pushSection('layout', {
            "pos_x":  '100',
            "pos_y":  '100',
            "size_x": '640',
            "size_y": '480',
            "sash_pos": '200',
            "xPos_access": '100',
            "yPos_access": '100',
            "xSize_access": '-1',
            "ySize_access": '-1',
            "accesswindowstate": '',
            "windowstate": ''
            })
        self.pushSection('properties', {
            "server":    'localhost',
            "dialect":   'postgresql',
            "database":  '',
            "user":      '',
            "ubicacion": '/',
            "logginglevel": 'debug',
            "sessiontype":  'debug'
            })
        self.pushSection('format', {
            "factura":  'factura.txt',
            "remision": 'remision.txt'
            })

        ## if not self.pull('properties', "loggingeffectivelevel"):
            ## self.push('properties', "loggingeffectivelevel", 'debug')


import logging

logging.basicConfig(filename='bE.exe.log', level=logging.WARNING, format= "%(asctime)s:%(name)s:%(levelname)s:%(message)s", datefmt='%d %b %Y %H:%M:%S')

#~ logger = logging.getLogger('_       ')

#~ logger = logging.getLogger( 'logger' )
#~ if not logger.handlers :
    #~ hdlr = logging.FileHandler( "logger.log" )
    #~ hdlr.setFormatter( logging.Formatter( '%(asctime)s %(levelname)s %(message)s' ) )
    #~ logger.addHandler( hdlr )

## config = Parser()         # Para checar que el archivo .cfg está bien

## level = config.pull( 'properties', 'loggingLevel', 'warning' )
## logger.setLevel( eval( "logging." + level.upper( ) ) )

